import os.path

from gxl_ai_utils.utils import utils_file
from torch.ao.quantization.utils import func_list


def do_handle():
    """
    将emotion现有的数据搬到54本地盘中,并熟悉数据的长相
    :return:
    """
    origin_data_path = "/home/work_nfs13/yhdai/data/4o_data/emotion/"
    tmp_shard_path = "/home/xlgeng/tmp"
    # 得到所有的emotion类别，最终得到一个中英文转换的字典
    # emotion_info_path_list = utils_file.get_file_path_list_for_wav_dir(tmp_shard_path, suffix='.emotion')
    # print(emotion_info_path_list)
    # emotion_info_list = []
    # for emotion_file_path in emotion_info_path_list:
    #     emotion_info = utils_file.load_first_row_clean(emotion_file_path)
    #     emotion_info_list.append(emotion_info)
    # print(emotion_info_list)
    # emotion_info_set = set(emotion_info_list)
    # print(emotion_info_set)
    # emotion_dict = {
    #     'FEAR': '恐惧',
    #     'ANGER': '愤怒',
    #     'HAPPY': '开心',
    #     'SAD': '悲伤',
    #     'SURPRISE': '惊讶',
    #     'DISGUST': '厌恶',
    #     'NEUTRAL': '中性'
    # }

    # 将emotion现有的数据搬到54本地盘中
    # 使用shell命令

    # 得到shards_list.txt
    # partitions = ['shards', 'shards_dev','shards_test']
    # data_dir='/home/node54_tmpdata/xlgeng/emotion_data'
    # for partition in partitions:
    #     tmp_data_dir = os.path.join(data_dir, partition,partition)
    #     tar_file_path_list = utils_file.get_file_path_list_for_wav_dir(tmp_data_dir, suffix='tar')
    #     manifest_list_path = os.path.join(tmp_shard_path, 'shards_list.txt')
    #     utils_file.write_list_to_file(tar_file_path_list, manifest_list_path)

    partitions = ['shards_test']
    data_dir = '/home/node54_tmpdata/xlgeng/emotion_data'
    for partition in partitions:
        tmp_data_dir = os.path.join(data_dir, partition, partition)
        child_dir_path_list = os.listdir(tmp_data_dir)
        print(child_dir_path_list)
        for child_name in child_dir_path_list:
            now_dir_path = os.path.join(tmp_data_dir, child_name)
            tar_file_path_list = utils_file.get_file_path_list_for_wav_dir(now_dir_path, suffix='tar')
            manifest_path = os.path.join(now_dir_path, 'shards_list.txt')
            utils_file.write_list_to_file(tar_file_path_list, manifest_path)





if __name__ == '__main__':
    do_handle()


